﻿using Albatross.WPF.Common.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace Albatross.SampleClient.ViewModels {
	[DataContract]
	public class Composite2ViewModel : WorkspaceViewModel {
		public Composite2ViewModel(string title) {
			Title = title;
		}
		public const string PromptPropertyName = "CanClose";
		private bool _canClose;
		public bool CanClose {
			get { return _canClose; }
			set {
				if (_canClose == value) { return; }
				RaisePropertyChanging(PromptPropertyName);
				_canClose = value;
				RaisePropertyChanged(PromptPropertyName);
			}
		}
		public override bool Closing(WPF.Common.IViewService svcs) {
			if (!CanClose) {
				if (svcs != null) {
					return svcs.ShowConfirmationMessageBox("Are you sure that you want to close " + Title);
				} else {
					return false;
				}
			} else {
				return true;
			}
		}
	}
}
